
public class Demo {
	public static void main(String[] args) throws InterruptedException {
		MyThread t1 = new MyThread();
		t1.start();
		
		
		Thread.sleep(3000);
		t1.setStopped(true);
	}

	static class MyThread extends Thread {
		public boolean isStopped;
		
		public void setStopped(boolean isStopped) {
			this.isStopped = isStopped;
		}
		
		public boolean isStopped() {
			return isStopped;
		}
		
		@Override
		public void run() {
			while(!isStopped) {
				//System.out.println("eeee");
			}
		}			
	};
	

}
